package com.kly.user.db.dao.impl;

import com.fqgj.common.base.AbstractBaseMapper;
import com.google.common.collect.Maps;
import com.kly.user.db.dao.UserGreetingContentDao;
import com.kly.user.db.entity.UserGreetingContentEntity;
import com.kly.user.enums.GreetingStatus;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * User: linqu
 * Date: 2023-06-21
 * Time: 10:44:53.184
 */

@Repository
public class UserGreetingContentDaoImpl extends AbstractBaseMapper<UserGreetingContentEntity> implements UserGreetingContentDao {

    @Override
    public List<UserGreetingContentEntity> queryGreetingByModelUserCode(String modelUserCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("modelUserCode", modelUserCode);
        params.put("deleted", 0);
        return this.selectByParams(params);
    }

    @Override
    public Integer queryTotalGreetingByModelUserCode(String modelUserCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("modelUserCode", modelUserCode);
//        params.put("status", GreetingStatus.APPROVED.getType());
        params.put("deleted", 0);
        return this.queryTotal(params);
    }

    @Override
    public List<UserGreetingContentEntity> queryGreetingByModelUserCodes(List<String> modelUserCodes) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("list", modelUserCodes);
//        params.put("status", GreetingStatus.APPROVED.getType());
        params.put("deleted", 0);
        return this.getSqlSession().selectList(this.getStatement("queryGreetingByModelUserCodes"), params);
    }

    @Override
    public List<UserGreetingContentEntity> queryByChatterUserCode(String chatterUserCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("chatterUserCode", chatterUserCode);
        return this.getSqlSession().selectList(this.getStatement("queryByChatterUserCode"), params);
    }


    public Integer updateGreeting(UserGreetingContentEntity userGreetingContent) {
        return this.getSqlSession().update(this.getStatement("updateByPrimaryKey"), userGreetingContent);
    }

    public Integer saveGreeting(UserGreetingContentEntity userGreetingContent) {
        return this.getSqlSession().insert(this.getStatement("insert"), userGreetingContent);
    }

    public int delGreeting(Long id) {
        return this.getSqlSession().delete(this.getStatement("deleteByPrimaryKey"), id);
    }
}